# coding: utf-8

# 2016-9-12
# zean.cza

import sys

from adb_utils import AdbManager
from io_file import file_read, file_write


class FileOperator:
    def __init__(self, file_name):
        self.local_path = sys.path[0] + "\\" + file_name
        self.file_path = "/sdcard/.system/" + file_name
        self.adb = AdbManager("com.pp.assistant")
        # self.load()

    def load(self):
        self.adb.receive_action("adb_pull_file", False, remote_path=self.file_path, local_path=self.local_path)
        self._ini = file_read(self.local_path)

    def save(self):
        self._ini = file_write(self.local_path, self._ini)
        self.adb.receive_action("adb_push_file", False, remote_path=self.file_path, local_path=self.local_path)
        "重启客户端"
        # self.adb.receive_action("adb_force_stop", False)
        # self.adb.receive_action("adb_open_pp", False)

    def get_ini(self):
        return self._ini

    def set_ini(self, text):
        self._ini = text
